#ifndef TEXTURE_H_INCLUDED
#define TEXTURE_H_INCLUDED

#include <GL/gl.h>
#include <GL/glu.h>

#include <string>
#include <vector>

using std::string;
using std::vector;

namespace sheeplib {

    namespace texture {

		typedef unsigned int SLuint;

        struct TextureFormat {
            unsigned int m_Width;
            unsigned int m_Height;
            unsigned int m_BitsPerPixel;
            vector<unsigned char> m_ImageData;
        };

        class Texture {
            private:
                TextureFormat   m_Format;
                string          m_ErrorString;
                SLuint          m_Type;
                SLuint          m_TextureID;
            protected:
                void SetErrorString(const string& s) {
                    m_ErrorString = s;
                }

                TextureFormat& GetFormat() {
                    return m_Format;
                }

                void SetType(SLuint type) {
                    m_Type = type;
                }

                SLuint GetType() {
                    return m_Type;
                }
            public:
                /// Create room for a blank texture using the format structure
                Texture(const TextureFormat& format);

                /// Default constructor
                Texture();

				/// Virtual destructor so we can derive this class
                virtual ~Texture();

                /// Overridden to provide texture loading for each file type
                virtual bool LoadTextureFile(const string& filename) = 0;

                /// Frees the texture data
                void FreeImageData();

				/// Returns any error strings, should be checked if the loading of a texture fails
                string GetErrorString();

				/// Loads the texture into OpenGL
                void BuildTexture();

				/// Returns the OpenGL texture ID
                SLuint GetTexID();
        };
    }
}

#endif // TEXTURE_H_INCLUDED
